<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<?php echo javascript_include_tag("traitement.js"); ?>

<?php $action = ""; ?>
<?php $url = 'traitement/' ?>
<?php if(isset($lot)) : ?>
    <?php if($form->getObject()->isNew()) $url = $url.'createTraitementLot?id_lot='.$lot->getIdLot().'&id_type_traitement='.$type_traitement->getIdTypeTraitement(); else $url = $url.'update?id_traitement='.$form->getObject()->getIdTraitement(); ?>
<?php elseif(isset($echantillon)) : ?>
    <?php if($form->getObject()->isNew()) $url = $url.'createTraitementEchantillon?id_echantillon='.$echantillon->getIdEchantillon().'&id_type_traitement='.$type_traitement->getIdTypeTraitement(); else $url = $url.'update?id_traitement='.$form->getObject()->getIdTraitement(); ?>
<?php elseif(isset($mesure)) : ?>
    <?php if($form->getObject()->isNew()) $url = $url.'createTraitementMesure?id_mesure='.$mesure->getIdMesure().'&id_type_traitement='.$type_traitement->getIdTypeTraitement(); else $url = $url.'update?id_traitement='.$form->getObject()->getIdTraitement(); ?>
<?php endif; ?>
    
    <?php //if(isset($lot)) $action = url_for('traitement/'.($form->getObject()->isNew() ? 'createTraitementLot' : 'update').(!$form->getObject()->isNew() ? '?id_traitement='.$form->getObject()->getIdTraitement() : '?id_lot='.$lot->getIdLot())); ?>
<?php $action = url_for($url); ?>

<form action="<?php echo $action ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table class="formulaire">
      <thead>
          <tr><th colspan="3">Fiche traitement</th></tr>
      </thead>
    <tfoot>
      <tr>
        <td colspan="2">
          <?php echo $form->renderHiddenFields(false) ?>
          <input type="submit" value="Enregistrer" class="submit" />
          <?php if($form->getObject()->isNew()) : ?>
            <?php if(isset($lot)) : ?>
                <a href="<?php echo url_for('lot/show?id_lot='.$lot->getIdLot()) ?>" class="submit">Annuler</a>
            <?php elseif(isset($echantillon)) : ?>
                <a href="<?php echo url_for('echantillon/show?id_echantillon='.$echantillon->getIdEchantillon()) ?>" class="submit">Annuler</a>
            <?php elseif(isset($mesure)) : ?>
                <a href="<?php echo url_for('mesure/show?id_mesure='.$mesure->getIdMesure()) ?>" class="submit">Annuler</a>
            <?php endif; ?>
          <?php else : ?>
            <a href="<?php echo url_for('traitement/show?id_traitement='.$traitement->getIdTraitement()) ?>" class="submit">Annuler</a>
          <?php endif; ?>
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?php echo $form->renderGlobalErrors() ?>
        <?php echo $sousForm->renderGlobalErrors() ?>
        <tr>
            <th>N° machine</th>
            <td><?php echo $form['numero_fiche_machine'] ?></td>
            <td><?php echo $form['numero_fiche_machine']->renderError() ?></td>
        </tr>
        <tr>
            <th>Lieu</th>
            <td><?php echo $form['id_lieu'] ?></td>
            <td><?php echo $form['id_lieu']->renderError() ?></td>
        </tr>
        <?php if(isset($echantillon)) : ?>
        <tr>
            <th>Date du traitement</th>
            <td>
                <input id="label_choix_date" disabled="disabled" value="<?php if ($form->getObject()->getDateDebutTraitement()) echo $form->getObject()->getDateTimeObject('date_debut_traitement')->format('D, d M, Y'); ?>"></input>
                <?php echo $form['date_debut_traitement'] ?>
            </td>
            <td><?php echo $form['date_debut_traitement']->renderError() ?></td>
        </tr>
        <?php endif; ?>
        <tr>
            <th>Durée du traitement (minutes)</th>
            <td><?php echo $form['duree_traitement'] ?></td>
            <td><?php echo $form['duree_traitement']->renderError() ?></td>
        </tr>
        <tr>
            <th>Succès</th>
            <td><?php echo $form['ok'] ?></td>
            <td><?php echo $form['ok']->renderError() ?></td>
        </tr>
        <tr>
            <th>Fichier ou dossier complémentaire</th>
            <td><?php echo $form['repertoire'] ?></td>
            <td><?php echo $form['repertoire']->renderError() ?></td>
        </tr>
        <?php echo $sousForm ?>
    </tbody>
  </table>
</form>
